//
//  YDAboutUsViewController.m
//  PeiZiWangBei
//
//  Created by 巨彦新 on 2018/1/2.
//  Copyright © 2018年 LK-IOS. All rights reserved.
//

#import "YDAboutUsViewController.h"
#import "YDAboutUsCell.h"

@interface YDAboutUsViewController ()<UITableViewDataSource>
@property (nonatomic, strong)UIView *iconView;

@property (nonatomic, strong)UITableView *tableview;

@property (nonatomic, strong)UILabel *xieyiLbl;



@end

@implementation YDAboutUsViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.view.backgroundColor = NumberColor(255, 255, 255);
    self.title = @"关于我们";
    [self iconView];
    [self tableview];
    [self xieyiLbl];
    
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 3;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    YDAboutUsCell *cell = [YDAboutUsCell cellWithTableview:tableView];
    
    if (indexPath.row == 0) {
        cell.title.text = @"当前版本：";
        cell.detail.text = [NSString stringWithFormat:@"V%@",[SYUserInformation sharedInstance].appVersion];
        
    }
    else if (indexPath.row == 1)
    {
        cell.title.text = @"联系方式：";
        cell.detail.text = CustomerPhone;
    }
    else
    {
        cell.title.text = @"工作时间：";
        cell.detail.text = @"09:00-12:00/13:30-18:00";
    }
    return cell;
    
}


- (void)xieyiDidSelected
{
    YDAgreementController *vc = [[YDAgreementController alloc] init];
    vc.agreementCategory = Registration;
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
}


-(UIView *)iconView
{
    if (!_iconView) {
        _iconView = [[UIView alloc] init];
        [self.view addSubview:_iconView];
        [_iconView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.right.equalTo(self.view);
            make.height.equalTo(isPhoneX ? @(rateX812(182)) : @(rate750(182)));
            
        }];
        UIImageView *icon = [[UIImageView alloc] init];
        icon.contentMode = UIViewContentModeScaleAspectFit;
        [_iconView addSubview:icon];
        [icon mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@(rate375(137)));
            make.right.equalTo(@(rate375(-136)));
            if (isPhoneX) {
                make.top.equalTo(@(rateX812(17)));
                make.bottom.equalTo(@(rateX812(-21)));
            }else
            {
                make.top.equalTo(@(rate750(17)));
                make.bottom.equalTo(@(rate750(-21)));
            }
        }];
         icon.image = [UIImage imageNamed:@"wd-yijianfankui"];
        
        _iconView.backgroundColor = [UIColor colorWithHexString:mainGray];
        
    }
    return _iconView;
}

-(UITableView *)tableview
{
    if (!_tableview) {
        _tableview = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
        [self.view addSubview:_tableview];
       
        CGFloat rowHeight = isPhoneX ? rateX812(34) :rate750(34);
      
        [_tableview mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(self.view);
            make.top.equalTo(self->_iconView.mas_bottom).offset(0);
            make.height.equalTo(@(rowHeight * 3));
        }];
        _tableview.separatorColor = [UIColor colorWithHexString:mainGray];
        _tableview.scrollEnabled = NO;
        _tableview.dataSource = self;
        _tableview.rowHeight = rowHeight;
        _tableview.separatorInset = UIEdgeInsetsMake(0, rate375(17), 0, rate375(19));
        _tableview.separatorColor = NumberColor(247, 247, 247);
        _tableview.backgroundColor = self.view.backgroundColor;
        _tableview.tableFooterView = [UIView new];
        if (isIos11) {
            _tableview.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        }
    }
    return _tableview;
}

-(UILabel *)xieyiLbl
{
    if (_xieyiLbl == nil) {
        UILabel *passPostLabel = [[UILabel alloc] init];
        [self.view addSubview:passPostLabel];
        passPostLabel.textColor = NumberColor(62, 89, 167);
        NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:@"《用户服务协议》" attributes:@{NSUnderlineStyleAttributeName:@(NSUnderlineStyleSingle)}];
        
        passPostLabel.attributedText = attribtStr;
        passPostLabel.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        passPostLabel.textAlignment = NSTextAlignmentRight;
        [passPostLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.view.mas_centerX);
            if (isPhoneX) {
                make.bottom.equalTo(self.view.mas_bottom).offset(-rateX812(20+34));
            }else{
                make.bottom.equalTo(self.view.mas_bottom).offset(-rate750(20));
            }
        }];
        passPostLabel.userInteractionEnabled = YES;
        [passPostLabel addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(xieyiDidSelected)]];
        
        _xieyiLbl = passPostLabel;
        
        
        
    }
    return _xieyiLbl;
}
@end
